<template>
  <div class="package-basic">
    <el-form ref="form" :model="form" label-width="220px">
      <el-form-item label="分类">
        <template v-for="(item,index) in form.select">
          <el-select
            v-model="item.selected"
            :disabled="true"
            :key="index"
            :placeholder="item.placeholder?item.placeholder:'请选择'"
            style="margin-right:10px"
          >
            <el-option v-for="v in item.options" :key="v.value" :label="v.label" :value="v.value"/>
          </el-select>
        </template>
      </el-form-item>
      <el-form-item label="课程包名称">
        <el-input v-model="form.packageName" :disabled="true"/>
      </el-form-item>
      <el-form-item label="是否免费">
        <el-radio v-model="form.free" :label="true" :disabled="true">是</el-radio>
        <el-radio v-model="form.free" :label="false" :disabled="true">否</el-radio>
      </el-form-item>
      <el-form-item label="定价">
        <el-input v-model="form.original" :disabled="true" placeholder="0.00" />
      </el-form-item>
      <el-form-item label="优惠价">
        <el-input v-model="form.discount" :disabled="true" placeholder="0.00"/>
      </el-form-item>
      <el-form-item label="课程包有效期">
        <el-radio v-model="form.until" :label="1" :disabled="true">固定天数</el-radio>
        <el-radio v-model="form.until" :label="2" :disabled="true">固定日期</el-radio>
        <el-radio v-model="form.until" :label="3" :disabled="true">无限期</el-radio>
        <p v-if="form.until === 1" style="color:#8a8a8a;margin: 10px 0 0;">
          有效天数
          <el-input-number v-model="form.day" :min="1" :max="100" :disabled="true" style="margin-left:10px;"/>
        </p>
        <p v-if="form.until === 2" style="color:#8a8a8a;margin: 10px 0 0;">
          有效日期
          <el-date-picker
            v-model="form.date"
            :disabled="true"
            type="daterange"
            range-separator="|"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            style="margin-left:10px;"
          />
        </p>
      </el-form-item>
      <el-form-item label="课程包协议">
        <el-select v-model="form.deal" :disabled="true">
          <el-option
            v-for="v in form.dealOptions"
            :key="v.value"
            :label="v.label"
            :value="v.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="nextStep">下一步</el-button>
        <el-button @click="handleCancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  components: {
  },
  data() {
    return {
      form: {
        packageName: '',
        original: '',
        discount: '',
        free: false,
        until: 3,
        day: 1,
        date: [],
        deal: '',
        dealOptions: [],
        select: [
          {
            selected: 'low',
            options: [
              {
                label: '初级',
                value: 'low'
              }
            ]
          },
          {
            selected: '',
            options: []
          },
          {
            selected: '',
            options: []
          }
        ]
      }
    }
  },
  mounted() {
    console.log(this.$route.params)
  },
  methods: {
    nextStep() {
      this.$emit('goNext')
    },
    handleCancel() {
      this.$router.go(-1)
    }
  }
}
</script>

<style lang="scss" scoped>
.package-basic {
  .el-form {
    margin-top: 30px;
    .el-input {
      width: 200px;
    }
    .el-select {
      width: 130px;
    }
  }
}
</style>
